import request from '@/utils/request'
import type { LoginQRCode, SendData, LoginForPhoneData, LoginResult, RegisterData, AccountLoginData } from './types'


class APIAuth {
    /** 二维码 URL 获取 */
    static loginQRCode() {
        return request<any, ResponseData<LoginQRCode>>({
            url: '/WeChat/loginQRCode',
            method: 'POST'
        })
    }

    /** 判断用户是否关注公众号并且允许登录 */
    static checkLoginState(scene_str: string) {
        return request<any, ResponseData<LoginResult>>({
            url: '/WeChat/checkLoginState',
            method: 'POST',
            data: { scene_str }
        })
    }

    /** 发送验证码 */
    static smsSend(data: SendData) {
        return request<any, ResponseData>({
            url: '/sms/send',
            method: 'POST',
            data
        })
    }

    /** 手机号登录 */
    static loginForPhone(data: LoginForPhoneData) {
        return request<any, ResponseData<LoginResult>>({
            url: '/loginForPhone',
            method: 'POST',
            data
        })
    }
    /** 绑定手机号 */
    static changePhone(data: LoginForPhoneData, headers: any) {
        return request<any, ResponseData>({
            url: '/changePhone',
            method: 'POST',
            data,
            headers
        })
    }

    /** 手机号注册 */
    static registerForPhone(data: RegisterData) {
        return request<any, ResponseData>({
            url: '/registerForPhone',
            method: 'POST',
            data
        })
    }

    static accountLogin(data: AccountLoginData) {
        return request<any, ResponseData>({
            url: '/login',
            method: 'POST',
            data
        })
    }

    /** 获取个人基本信息 */
    static getPersonal() {
        return request<any, ResponseData<any>>({
            url: '/getPersonal',
            method: 'POST',
        })
    }

    /** 获取个人信息，已合并关于用户数据接口 */
    static getAllUser() {
        return request<any, ResponseData<any>>({
            url: '/getAllUser',
            method: 'POST',
        })
    }

    static passwordReset(data: any) {
        return request<any, ResponseData>({
            url: '/passwordReset',
            method: 'POST',
            data
        })
    }

}

export default APIAuth